/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package it.biblioteca;

import it.biblioteca.util.Book;
import it.biblioteca.util.BookList;
import it.biblioteca.util.ComboFields;
import it.biblioteca.util.UtilFileOperation;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import javax.swing.UIManager;

/**
 *
 * @author Andrea Di Grazia, Massimiliano Giovine
 * @date 29-set-2008
 * @file BibliotecaMainClass.java
 */
public class BibliotecaMainClass {
    public static void main(String [] args) throws FileNotFoundException{
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
        }
        
        File xml_database = new File("./dataBase.xml");
        ArrayList <Book> book_list;
        
        if(!xml_database.exists()){book_list= new ArrayList();}        
        else{ book_list = UtilFileOperation.getBookList();}
        
        
        BookList my_list = new BookList();
        my_list.setBookList(book_list);
        
        File xml_combofields = new File("./comboFields.xml");
        ComboFields fields;
        ArrayList <String> field_list;
        if(!xml_combofields.exists()){
            field_list = new ArrayList();
            fields = new ComboFields();
            fields.setFields(field_list);
        }
        else{
            fields = UtilFileOperation.getComboFields();
        }
        
   
        
        BibliotecaInitialChoice init = new BibliotecaInitialChoice(my_list,fields);
        init.setLocationRelativeTo(null);
        init.setVisible(true);
    }

}
